support instance reuse for WASIp3 HTTP components#3328
support instance reuse for WASIp3 HTTP components#3328dicej merged 1 commit intospinframework:mainfrom
Conversation
| tracing::trace!("Adding archive layer for all files in source {:?}", &source); | ||
| let working_dir = tempfile::tempdir()?; | ||
| let archive_path = crate::utils::archive(source, &working_dir.into_path()) | ||
| let archive_path = crate::utils::archive(source, &working_dir.keep()) |
There was a problem hiding this comment.
This fixes a clippy deprecation warning.
|
Very cool, I'm really glad this seems to have worked out without too much trouble!
I think this should be configurable via runtime config, plus env vars and/or CLI options, but not The |
|
At one point we discussed exposing app developers to a mix of "new instance" and "reused instance" in the CLI in order to help developers detect latent reuse bugs, e.g. by randomly deciding to biff the current instance, or by having a default reuse configuration that developers would hit a mix in any non-trivial testing. Is that on the agenda? |
|
oh, good point: I had forgotten about that. And yes, we should definitely make these values configurable as ranges, within which we randomize |
|
Sounds good. I'm on a roll right now adding async support to |
|
I just pushed an update that adds the configuration support we discussed. I noticed that the existing mechanism to configure |
b826137 to
4783ff6
Compare
4783ff6 to
866f03b
Compare
This makes use of the new `wasmtime_wasi_http::handler::ProxyHandler` utility, which provides both serial and concurrent instance reuse. We could hypothetically enable opt-in serial reuse for WASIp2 components as well using the same pattern (which is what `wasmtime serve` does), but I'll leave that for a follow-up PR, if desired. This hard-codes the configuration values (max reuse count = 128, max concurrent reuse count = 16, idle timeout = 1s) for now. Once we've decided where these values should be configured (e.g. in the spin.toml manifest, in the runtime config, or at runtime via the component itself), we can support that. See https://github.com/WebAssembly/wasi-http/issues/190 for related discussion. Signed-off-by: Joel Dice <joel.dice@fermyon.com> add support for configuring instance reuse via CLI options Signed-off-by: Joel Dice <joel.dice@fermyon.com> update to Wasmtime 39.0.1 Signed-off-by: Joel Dice <joel.dice@fermyon.com>
866f03b to
58a80ba
Compare
|
@dicej do you have notes for a reviewer on how to test the different behaviors added here? Thanks! |
I did most of my testing using
I also tested a variation by adding a When I was testing, I cheated by patching the Hope that helps. Happy to provide more detail if needed. |
fibonacci1729
left a comment
There was a problem hiding this comment.
Code looks good to me!
I added an issue to track documenting this feature: spinframework/spin-docs#158
This makes use of the new
wasmtime_wasi_http::handler::ProxyHandlerutility, which provides both serial and concurrent instance reuse.We could hypothetically enable opt-in serial reuse for WASIp2 components as well using the same pattern (which is what
wasmtime servedoes), but I'll leave that for a follow-up PR, if desired.